{#{% import 'admin/layout.html' as layout with context %}#}
{% extends 'AdminLTE/base.html' %}

{% block page_body %}
    <div class="wrapper">
        <!--头部-->
        <header class="main-header">
            <a href="#" class="logo">
                <span class="logo-mini"><b>C</b></span>
                <span class="logo-lg"><b>Cstackess</b></span>
            </a>
            <nav class="navbar navbar-static-top">
                <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </a>
                <div class="navbar-custom-menu">
                    <ul class="nav navbar-nav">
                        <li class="dropdown user user-menu">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                <img src="{{ url_for('static', filename='images/cstackess.jpg') }}" class="user-image"
                                     alt="User Image">
                                <span class="hidden-xs">admin</span>
                            </a>
                            <ul class="dropdown-menu">
                                <li class="user-header">
                                    <img src="{{ url_for('static', filename='images/cstackess.jpg') }}"
                                         class="img-circle" alt="User Image">
                                    <p>
                                        <span>admin</span>
                                        <small>admin@gogogo.com</small>
                                    </p>
                                </li>
                                <li class="user-footer">
                                    <div class="pull-left">
                                        <a href="#" class="btn btn-default btn-flat">统计信息</a>
                                    </div>
                                    <div class="pull-right">
                                        <a href="#" class="btn btn-default btn-flat">退出登录</a>
                                    </div>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </nav>
        </header>
        <!--侧边栏-->
        <aside class="main-sidebar">
            <section class="sidebar">
                <!--搜索-->
                <form action="#" method="get" class="sidebar-form">
                    <div class="input-group">
                        <input type="text" name="q" class="form-control" placeholder="Search...">
                        <span class="input-group-btn">
                <button type="submit" name="search" id="search-btn" class="btn btn-flat">
                    <i class="fa fa-search"></i>
                </button>
              </span>
                    </div>
                </form>
                <ul class="sidebar-menu">
                    <li class="header">功能导航</li>
                    {#                    {{ layout.menu() }}#}
                    {#                    {{ layout.menu_links() }}#}

                    <!--重写菜单layout.menu，其实只是只是给item.name加入<span></span>-->
                    {% set menu_root = admin_view.admin.menu() %}
                    {% for item in menu_root %}
                        {% if item.is_category() %}
                            <!--r如果是多级菜单-->
                            {% set children = item.get_children() %}
                            {% if children %}
                                {% set class_name = item.get_class_name() %}
                                <!--如果是active-->
                                {% if item.is_active(admin_view) %}
                                    {#                                    <li class="active dropdown">#}
                                    <li class="treeview active">
                                        {% else %}
                                        {#                                    <li class="dropdown">#}
                                    <li class="treeview">
                                {% endif %}
                            <a href="#">
                                {#                            <a class="dropdown-toggle" data-toggle="dropdown" href="javascript:void(0)">#}
                                {#                                {% if item.class_name %}<span class="{{ item.class_name }}"></span> {% endif %}#}
                                {% if item.class_name %}<i class="{{ item.class_name }}"></i> {% endif %}
                                {#{{ layout.menu_icon(item) }}#}
                                <span>{{ item.name }}</span>
                                {#                                <b class="caret"></b>#}
                                <span class="pull-right-container"><i class="fa fa-angle-left pull-right"></i></span>
                            </a>
                            <!--子菜单-->
                            <ul class="treeview-menu">
                                {#                                                                <li><a href="{{ url_for('main.notifyedit') }}"><i class="fa fa-circle-o"></i> 编辑</a></li>#}
                                {#                                                                <li><a href="{{ url_for('main.notifylist') }}"><i class="fa fa-circle-o"></i> 查询</a></li>#}

                                {% for child in children %}
                                    {% set class_name = child.get_class_name() %}
                                    {% if child.is_active(admin_view) %}
                                        <li class="active{% if class_name %} {{ class_name }}{% endif %}">
                                            {% else %}
                                        <li{% if class_name %} class="{{ class_name }}"{% endif %}>
                                    {% endif %}
                                <a href="{{ child.get_url() }}"{% if child.target %}
                                   target="{{ child.target }}"{% endif %}>
                                    {{ layout.menu_icon(child) }}{{ child.name }}</a>
                                </li>
                                {% endfor %}

                            </ul>

                            {#                            <ul class="dropdown-menu">#}
                            {#                                {% for child in children %}#}
                            {#                                    {% set class_name = child.get_class_name() %}#}
                            {#                                    {% if child.is_active(admin_view) %}#}
                            {#                                        <li class="active{% if class_name %} {{ class_name }}{% endif %}">#}
                            {#                                            {% else %}#}
                            {#                                        <li{% if class_name %} class="{{ class_name }}"{% endif %}>#}
                            {#                                    {% endif %}#}
                            {#                                <a href="{{ child.get_url() }}"{% if child.target %}#}
                            {#                                   target="{{ child.target }}"{% endif %}>#}
                            {#                                    {{ layout.menu_icon(child) }}{{ child.name }}</a>#}
                            {#                                </li>#}
                            {#                                {% endfor %}#}
                            {#                            </ul>#}
                            </li>
                            {% endif %}
                        {% else %}
                            <!--如果不是多级菜单-->
                            {% if item.is_accessible() and item.is_visible() %}
                                {% set class_name = item.get_class_name() %}
                                {% if item.is_active(admin_view) %}
                                    <li class="active{% if class_name %} {{ class_name }}{% endif %}">
                                        {% else %}
                                    <li{% if class_name %} class="{{ class_name }}"{% endif %}>
                                {% endif %}
                            <a href="{{ item.get_url() }}"{% if item.target %} target="{{ item.target }}"{% endif %}>
                                {{ layout.menu_icon(item) }}<span>{{ item.name }}</span></a>
                            </li>
                            {% endif %}
                        {% endif %}
                    {% endfor %}

                    <!--重写菜单layout.menu_links，其实只是只是给item.name加入<span></span>-->
                    {% set links = admin_view.admin.menu_links() %}
                    {% for item in links %}
                        {% if item.is_accessible() and item.is_visible() %}
                            <li>
                                <a href="{{ item.get_url() }}">{{ layout.menu_icon(item) }}<span>{{ item.name }}</span></a>
                            </li>
                        {% endif %}
                    {% endfor %}

                </ul>
            </section>
        </aside>

        <div class="content-wrapper">
            {% block messages %}
                {{ layout.messages() }}
            {% endblock %}

            <!--原amdinetl-->
            {% block navbar %}
                <section class="content-header">
                    <h1>{{ admin_view.name|capitalize }}</h1>
                </section>
            {% endblock %}
            <!--导航栏-->
            {% block brand %}
            {% endblock %}

            <!--正文-->
            <section class="content">
                {#                {% block content %}{% endblock %}#}

                {% set render_ctx = h.resolve_ctx() %}
                {% block body %}{% endblock %}
            </section>
        </div>
        <!--页脚-->
                <footer class="main-footer">
                    <div class="pull-right hidden-xs">
                        <b>版本号</b> 0.1
                    </div>
                    Copyright &copy; 2019 <a href="https://github.com/cstackess">cstackess</a>
                </footer>
        <!--模态窗口-->
        <div class="modal-wrapper">
            <div id="alert-modal" class="modal fade">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <!--<button type="button" class="close" data-dismiss="modal" aria-label="Close">-->
                            <!--<span aria-hidden="true">&times;</span></button>-->
                            <h4 class="modal-title">提示</h4>
                        </div>
                        <div class="modal-body">
                            提示内容
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default pull-left btn-no" data-dismiss="modal">取消
                            </button>
                            <button type="button" class="btn btn-default btn-yes" data-dismiss="modal">确定</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

{% endblock %}